"""django32_celery URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/3.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from django.views.generic.base import TemplateView
from django.conf.urls import url, include
from .views import login_auth
# 处理 setting中debug =False的时间 ,静态文件丢失的情况
from django.views import static  ##新增
from django.conf import settings  ##新增
from django.conf.urls import url  ##新增
from .views import MyTokenObtainPairView  # 导入自定义的视图
from .views import bad_request, permission_denied, page_not_found, server_error

from rest_framework.documentation import include_docs_urls
from rest_framework_simplejwt.views import (
    # TokenObtainPairView,
    TokenRefreshView,
    TokenVerifyView
)

urlpatterns = [
    path('admin', admin.site.urls),
    # 文档
    path(r'docs/', include_docs_urls(title='Pastebin API')),
    path('', TemplateView.as_view(template_name='templates/index.html')),
    url('v1/login_auth/', login_auth, name="login_auth"),  # 首先登录
    url(r'^static/(?P<path>.*)$', static.serve, {'document_root': settings.STATIC_ROOT}, name='static'),

    # 任务应用
    path("task/", include('c_apps.urls'), name='tasks'),
    # 运维应用
    path("devops/", include('ops.urls'), name='devops'),

    # token相关
    path('api/token/', MyTokenObtainPairView.as_view(), name='token_obtain_pair'),
    path('api/token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
    # 下面这个是用来验证token的，根据需要进行配置
    path('api/token/verify/', TokenVerifyView.as_view(), name='token_verify')

]
handler400 = bad_request
handler403 = permission_denied
handler404 = page_not_found
handler500 = server_error
